package com.codeoss.framework.view.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.converter.IConverter;
import com.codeoss.framework.converter.IConverterStore;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.Hidden;
import com.codeoss.framework.view.service.IVariableService;

@Service
public class HiddenComponentService extends ComponentService {
	@Autowired
    private IVariableService variableService;
	@Autowired
	private IConverterStore converterStore;
	@Override
	public void processValue(YunContext yunContext, Component component,Map<String,String> paraMap,Map<String,Object> dataMap) {
		// TODO Auto-generated method stub
		Hidden hidden=(Hidden)component;
		if(paraMap.containsKey(hidden.getId())) {
			String dataType=hidden.getDataType();
			String sValue=paraMap.get(hidden.getId());	
			
			IConverter converter=converterStore.getConverter(dataType);
			Object value=converter.convertStringToObject(sValue);
			variableService.setVariableValue(yunContext, hidden.getVarName(), value);
		}
	}
}
